package com.sc.nft.entity.req;

import com.sc.nft.enums.GasConsumeTypeEnum;
import com.sc.nft.exception.GlobalRunTimeException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

@Data
public class EcologyCastGasRequest {
    
    @ApiModelProperty(value = "是否开启上链费配置")
    private Boolean gasConf = Boolean.FALSE;
    
    @ApiModelProperty(value = "消耗类型")
    private GasConsumeTypeEnum consumeType;
    
    @ApiModelProperty(value = "消耗额度")
    private BigDecimal consumeCost;
    
    
    public void checkEcologyCastGas() {
        if (!gasConf) {
           return;
        }
        if (Objects.isNull(consumeType) || Objects.isNull(consumeCost)) {
            throw new GlobalRunTimeException("开启上链费配置情况下,消耗类型和余额不能为空");
        }
        
        if (consumeCost.compareTo(BigDecimal.ZERO)<1){
            throw new GlobalRunTimeException("上联费不能小于1");
        }
    }
    
}
